package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.ReturnList;
import com.atguigu.jxc.service.ReturnListGoodsService;
import com.atguigu.jxc.service.ReturnListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 杨林
 * @create 2023-01-29 22:51 星期日
 * description:
 */
@RestController
@RequestMapping("/returnListGoods")
public class ReturnListGoodsController {

    @Autowired
    ReturnListGoodsService returnListGoodsService;

    @Autowired
    ReturnListService returnListService;

    /**
     * 退货单保存
     * @param returnList
     * @param returnListGoodsStr
     * @return
     */
    @PostMapping("/save")
    public ServiceVO save(ReturnList returnList, String returnListGoodsStr){

        return returnListGoodsService.save(returnList,returnListGoodsStr);
    }


    /**
     * 退货单列表展示（可条件查询：单据号模糊、供应商、是否付款和日期区间）
     * @param returnNumber
     * @param supplierId
     * @param state
     * @param sTime
     * @param eTime
     * @return
     */
    @PostMapping("/list")
    public Map<String,Object> list(String returnNumber,
                                   Integer supplierId,
                                   Integer state,
                                   String sTime,
                                   String eTime){

        return returnListService.list(returnNumber,supplierId,state,sTime,eTime);
    }

    /**
     * 退货单商品信息
     * @param returnListId
     * @return
     */
    @PostMapping("/goodsList")
    public Map<String,Object> goodsList(Integer returnListId){

        return returnListGoodsService.goodsList(returnListId);
    }

    /**
     * 删除退货单
     * @return
     */
    @PostMapping("/delete")
    public ServiceVO delete(Integer returnListId){

        return returnListService.delete(returnListId);
    }


    /**
     * 退货统计（可根据 商品类别、商品编码或名称 条件查询）
     * @param sTime
     * @param eTime
     * @param goodsTypeId
     * @param codeOrName
     * @return
     */
    @PostMapping("/count")
    public String count(String sTime,
                        String eTime ,
                        Integer goodsTypeId,
                        String codeOrName){

        return returnListService.count(sTime,eTime,goodsTypeId,codeOrName);
    }

}
